const config = require('../../common/config');
const util = require('../../utils/util');
const app = getApp();

Page({
    data: {
        icon_add: config.WEB_ROOT + "/images/icons/add_data.png",
        venicleList: []
    },
    onLoad: function () {
        wx.setNavigationBarTitle({
            title: '车辆管理'
        })
        var that = this;
        wx.showLoading({
            title: '加载中..',
            icon: 'loading',
            duration: config.TIME_OUT,
            mask: true
        })

        wx.request({
            url: config.COMMPT_REQPATH,
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            method: 'POST',
            data: {
                accessToken: '',
                refreshToken: '',
                serviceName: 'venicleService',
                methodName: 'getMemberVenicles',
                reqData: JSON.stringify({
                    memberId: app.globalData.userInfo.memberId
                })
            },
            success: function (res) {
                var resultData = res.data;
                if (resultData.code == 1) {
                    util.debug(resultData);
                    that.setData({
                        venicleList: resultData.data.venicleList
                    })
                } else {
                    util.debug('veniclejs:获取车辆列表信息失败');
                    util.debug(resultData);
                }
            },
            fail: function (e) {
                util.debug(e.errMsg);
            },
            complete: function () {
                wx.hideLoading();
            }
        })
    }
})